'use strict';
angular.module('ui.bootstrap.carousel', ['ui.bootstrap'])
    .controller('CarouselController', ['$scope', '$timeout', '$transition', '$q', function        ($scope, $timeout, $transition, $q) {
}]).directive('carousel', [function() {
    return {

    }
}]);
angular.module('app', ['ui.router', 'app.services', 'app.controllers', 'ngResource', 'ngDialog', 'app.filters', 'ui.bootstrap', 'ngTable','rorymadden.date-dropdowns','angular-loading-bar'])


.run(function($rootScope, $state, $stateParams) {
	$rootScope.$state = $state;
	$rootScope.$stateParams = $stateParams;
	// add previous state property
	$rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState) {
		$state.previous = fromState;
	});
	$rootScope.$on('$stateChangeStart', function(event, next) {


	});

})
.config(function($stateProvider, $urlRouterProvider, $locationProvider, $httpProvider) {
	//$locationProvider.html5Mode(true);
	//initialize get if not there
    if (!$httpProvider.defaults.headers.get) {
        $httpProvider.defaults.headers.get = {};    
    }    

    // Answer edited to include suggestions from comments
    // because previous version of code introduced browser-related errors

    //disable IE ajax request caching
    $httpProvider.defaults.headers.get['If-Modified-Since'] = 'Mon, 26 Jul 1997 05:00:00 GMT';
    // extra
    $httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';
    $httpProvider.defaults.headers.get['Pragma'] = 'no-cache';
	$stateProvider
		.state('home', {
			abstract: true,
			templateUrl: 'views/home.html',
			controller: 'RootCtrl'
		})

	.state('home.main', {
		url: '/home',
		// abstract: true,
		templateUrl: 'views/main.html',
		controller: 'OverviewCtrl'
	})
	// .state('home.hr.main',{
	// 	url: '/home',
	// 	templateUrl: 'views/main.html',
	// 	controller: 'HotelUserCtrl',
	// 	controllerAs: 'vm'
	// })
	.state('home.product', {
		url: '/product',
		templateUrl: 'views/home/product.html',
	  // controller: 'ProductCtrl',
	  // controllerAs: 'vm'
	})
	.state('home.service', {
		url: '/service',
		templateUrl: 'views/home/service.html',
	  // controller: 'ServiceCtrl',
	  // controllerAs: 'vm'
	})
	.state('home.team', {
		url: '/team',
		templateUrl: 'views/home/team.html',
	  // controller: 'TeamCtrl',
	  // controllerAs: 'vm'
	})
	.state('home.showcase', {
		url: '/showcase',
		templateUrl: 'views/home/showcase.html',
	  // controller: 'ShowcaseCtrl',
	  // controllerAs: 'vm'
	})
	.state('home.aboutus', {
		url: '/aboutus',
		templateUrl: 'views/home/aboutus.html',
	  // controller: 'AboutusCtrl',
	  // controllerAs: 'vm'
	})
	.state('we', {
		url: '/we',
		templateUrl: 'views/we/home.html',
	  // controller: 'AboutusCtrl',
	  // controllerAs: 'vm'
	})
	
	//Common Router

	.state('beanbot', {
		url: '/beanbot',
		templateUrl: 'views/beanbot.html',
		controller: 'LoginCtrl'
	})


	$urlRouterProvider.otherwise('home');

});